<template>
	<view>
		<view ref="foodsWrapper" class="foods-wrapper bg-white" id="food-wrapper">
			<!-- <view class="foods"> -->
			<view class="food u-f" :class="food.productStock == 0 ? 'mask': ''" v-for="(food, index) in goods" :key="index">
					<image :src="food.mainPicture" class="pic radius " mode="widthFix"></image>
				<view class="pro-info ">
					<view>
						<text class="title texts-cut">{{ food.productName }}</text>
						<view class="tui-por-del text-cut">
							<view class="del-item" v-if="food.giveJf !== 0">
								<text>获得{{ food.giveJf}}积分</text>
							</view>
							<!-- <view> -->
							<!-- <view class="del-item" v-if="food.shareP">达人分享购买可赚{{ food.shareP }}元</view> -->
							<!-- <view class="del-item" v-if="bypassAccount == 0 && food.map.reward !== 0">佣金比例:{{ food.map.reward }}%</view> -->
						</view>
					</view>
					<!-- 加减 -->
					<view class="flexend">
						<view class="ms-box u-f-ac" v-if="food.buyLimit != 0">
							<view class="tit">秒杀价</view>
							<view class="colorr">限{{ food.buyLimit }}份</view>
						</view>
						<view class="food-btm">
							<view class="spec">
								<text class="food-price">￥9.9</text>
								<text class="line-through">￥99</text>
								<!-- <text class="text-gray">/{{food.company}}</text> -->
							</view>
		
							<view v-if="!food.skuOneName">
								<cartcontrol :food="food.map" @add="addCart" @dec="decreaseCart" v-if="food.count > 0"></cartcontrol>
								<view class="addcart round" @click.stop="addCart(food.map)" v-else><text>加入购物车</text></view>
							</view>
							<view v-else class="text-cut round" @click.stop="showSpec(food.map, food.skuList)">选规格</view>
							<view v-show="food.count > 0 && food.skuOneName" class="count">{{ food.count }}</view>
						</view>
						<text class="del">
							<text>销量 99+</text>
							<text class="productStock" v-if="food.productStock > 0 && food.productStock < 11">仅剩{{ food.productStock }}件</text>
							<text class="productStock" v-if="food.productStock < 1">暂时缺货</text>
						</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name:"goodsContainer",
		data() {
			return {
				
			};
		},
		props:{
			goods: {
				type: Array,
				default: function() {
					return [];
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
// 商品列表
.foods-wrapper {
	margin-top: 10px;
	overflow: hidden;
	padding: 20rpx 0 100rpx;
	min-height: 400rpx;
}
.food {
	margin-bottom: 15rpx;
	padding: 10rpx 20rpx;
	position: relative;
	.pic {
		width: 280rpx;
		height: auto;
		display: block;
		flex-shrink: 0;
		align-self: center;
	}
	.ms-box {
		position: relative;
		margin: 25rpx 0 12rpx;
		font-size: 24rpx;
		view {
			text-align: center;
			box-sizing: border-box;
		}
		.tit {
			padding: 5rpx 8rpx;
			background-color: #ff1216;
			color: #fff;
		}
		.colorr {
			padding: 3rpx 8rpx;
			border: 2rpx solid #ff1216;
			color: #ff1216;
			// flex: 1;
		}
	}
	.ms-box::before {
		content: '';
		position: absolute;
		bottom: -14rpx;
		left: 16rpx;
		width: 0;
		height: 0;
		border-left: 8rpx solid transparent;
		border-right: 8rpx solid transparent;
		border-top: 14rpx solid #ff1216;
		z-index: 1;
	}
}
.food::after {
	content: '';
	background-color: #f4f2f5;
	width: 100%;
	height: 2rpx;
	position: absolute;
	left: 0;
	bottom: -10rpx;
}
.flexend {
	align-items: flex-end;
}
.food,
.food-btm,
.content {
	display: flex;
	flex-direction: row;
}

.food-btm {
	position: relative;
}

.count {
	position: absolute;
	height: 40rpx;
	background-color: #f22222;
	color: #fff;
	min-width: 40rpx;
	line-height: 40rpx;
	text-align: center;
	border-radius: 40rpx;
	right: 0;
	bottom: 42rpx;
}
.pro-info {
	margin-left: 20rpx;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	flex: 2;
	min-height: 240rpx;
	right: 20rpx;
	.title {
		font-size: 30rpx;
	}

	.sub {
		font-size: 24upx;
	}

	.del {
		font-size: 22upx;
		color: #888888;
		margin: 12rpx 0;
	}
}

.food-btm {
	font-size: 20upx;
	display: flex;
	justify-content: space-between;
	width: 100%;
	.spec {
		& > text {
			margin-right: 10upx;
		}
	}

	.text-cut {
		background-color: #f22222;
		width: 120upx;
		height: 50upx;
		line-height: 50upx;
		text-align: center;
		font-size: 24upx;
		color: #fff;
	}
}

.food-price {
	color: #f22222;
	font-size: 36upx;
	font-weight: bold;
}

.productStock {
	color: #f22222;
	font-size: 26rpx;
	margin-left: 30rpx;
}
.tui-por-del {
	box-sizing: border-box;
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	margin-top: 5upx;
	.del-item {
		padding: 0 8upx;
		margin-top: 10upx;
		margin-right: 10upx;
		text-align: center;
		border: 1upx solid #F22222;
		border-radius: 10upx;
		font-size: 22upx;
		color: #F22222;
	}
	.del-item:last-child {
		margin-right: 0;
	}
}
.mask::after{
	content: '该商品已售罄';
	position: absolute;
	top: 0;
	left: 20rpx;
	display: flex;
	align-items: center;
	width: 100%;
	height: 100%;
	text-indent: 60rpx;
	background-color: rgba($color: #a0a0a0, $alpha: 0.1);
	color: #8799a3;
}
.mask{
	.pro-info .title{
		color: #8799a3;
	}
}
</style>
